package com.gin.kotlin.no_gay_alliance.adapter.community

import android.content.Context
import android.view.View
import com.gin.kotlin.no_gay_alliance.base.AbstractBindingRecyclerViewAdapter
import com.gin.kotlin.no_gay_alliance.base.MyHandler
import com.gin.kotlin.no_gay_alliance.databinding.ItemForumSubGroupBinding
import com.gin.kotlin.no_gay_alliance.model.ForumSubGroupModel

/**
 * 首页版面入口子组适配器
 * @constructor
 */
class ForumSubGroupAdapter(
    context: Context,
    handler: MyHandler,
    zebraStripe: Boolean = true,
    data: MutableList<ForumSubGroupModel> = mutableListOf()
) : AbstractBindingRecyclerViewAdapter<ItemForumSubGroupBinding, ForumSubGroupModel>(context, handler, zebraStripe, data) {
    /**
     * 当显示某一位置的item时的操作
     * @param holder ViewHolder
     * @param position Int
     * @param b ViewBinding
     * @param dataModel 数据对象
     */
    override fun onBindViewHolder(holder: ViewHolder<ItemForumSubGroupBinding>, position: Int, b: ItemForumSubGroupBinding, dataModel: ForumSubGroupModel) {
        //名称
        b.tv.text = dataModel.name
        // 可见性
        b.tv.visibility = if (b.tv.text.isEmpty()) View.GONE else View.VISIBLE
        // 设置适配器
        b.recyclerView.adapter = ForumEntryAdapter(context, handler, dataModel.entries!!)
    }
}